/* @flow weak */

import React, { Component } from 'react';
import {
  View,
  Text,
  StyleSheet,
  Image,
  Button,
} from 'react-native';
import PropTypes from 'prop-types'

import { connect } from 'react-redux';

import {testAction,showTabBar} from '../../Redux/actions/AppActions.js'

const _pushAction = () => {
  changeTabBar(!this.props.testShow);
}

const AppSearch = ({testShow,changeTabBar}) => (
  <View style={styles.container}>
    <Text>{testShow?"我要显示某个东西":"我要隐藏某个东西"}</Text>
    <Button
      title='push search'
      onPress={() => {
        this.props.changeTabBar(false);
      }}
    ></Button>
  </View>
);

AppSearch.navigationOptions = ({navigation,screenProps}) => {

  var showTab = navigation.state.params && navigation.state.params.showTab;

  return {
    tabBarVisible: showTab? showTab:false,

  }
}




const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
  },
});



//用来获取更新后的数据   监听数据更新
const mapStateToProps = (state,ownProps) => ({
  testShow: state.testShow,
})


//用来派发消息
const mapDispatchToProps = (dispatch,ownProps) => ({
  changeTabBar: (...args) => dispatch(showTabBar(...args)),
});

//用来进行数据流  和  控件的绑定关系
export default connect(mapStateToProps,mapDispatchToProps)(AppSearch)
